<!doctype html>


<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>iter.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>





<div class="colmask rightmenu">
<div class="colleft">
    <div class="col1">
      <!-- Column 1 start -->

<div id="title">
       <span class="fn">iter.js</span>
</div>

<div class="g-section g-tpl-75-25">
  <div class="g-unit g-first" id="description">
    Python style iteration utilities.
  </div>
  

        <div class="g-unit" id="useful-links">
          <div class="title">Useful links</div>
          <ol>
            <li><a href="closure_goog_iter_iter.js.source.html"><span class='source-code-link'>Source Code</span></a></li>
            <li><a href="http://code.google.com/p/closure-library/source/browse/closure/goog/iter/iter.js">Git</a></li>
          </ol>
        </div>
</div>

<h2 class="g-first">File Location</h2>
  <div class="g-section g-tpl-20-80">
    <div class="g-unit g-first">
      <div class="g-c-cell code-label">iter/iter.js</div>
    </div>
  </div>
<hr/>


  <h2>Classes</h2>
 <div class="fn-constructor">
        <a href="class_goog_iter_Iterator.html">
          goog.iter.Iterator</a><br/>
        <div class="class-details">Class/interface for iterators.  An iterator needs to implement a <code>next</code>
method and it needs to throw a <code>goog.iter.StopIteration</code> when the
iteration passes beyond the end.  Iterators have no <code>hasNext</code> method.
It is recommended to always use the helper functions to iterate over the
iterator or in case you are only targeting JavaScript 1.7 for in loops.</div>
 </div>
      
<br/>

  <div class="legend">
        <span class="key publickey"></span><span>Public</span>
        <span class="key protectedkey"></span><span>Protected</span>
        <span class="key privatekey"></span><span>Private</span>
  </div>









<div class="section">
  <table class="horiz-rule">


  </table>
</div>




  <h2>Global Functions</h2>





<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.iter.chain"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.iter.</span><span class="entryName">chain<span class="args">(<span class="arg">var_args</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span></div>
      </div>


     <div class="entryOverview">
       Takes zero or more iterators and returns one iterator that will iterate over
them in the order chained.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">var_args</span>
        : <div class="fullType">(<span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span><span>&nbsp;|&nbsp;</span><span class="type">undefined</span>)</div>
        <div class="entryOverview">Any number of iterator objects.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span></div>&nbsp;
            Returns a new iterator that will iterate over all the given iterators' contents.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_iter_iter.js.source.html#line392">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.iter.cycle"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.iter.</span><span class="entryName">cycle<span class="args">(<span class="arg">iterable</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span></div>
      </div>


     <div class="entryOverview">
       Create an iterator to cycle over the iterable's elements indefinitely.
For example, ([1, 2, 3]) would return : 1, 2, 3, 1, 2, 3, ...
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">iterable</span>
        : <div class="fullType">(<span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span><span>&nbsp;|&nbsp;</span><span class="type">{__iterator__: ?}</span><span>&nbsp;|&nbsp;</span><span class="type">{length: number}</span>)</div>
        <div class="entryOverview">The iterable object.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span></div>&nbsp;
            An iterator that iterates indefinitely over the values in <code>iterable</code>.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_iter_iter.js.source.html#line656">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.iter.dropWhile"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.iter.</span><span class="entryName">dropWhile<span class="args">(<span class="arg">iterable</span>,&nbsp;<span class="arg">f</span>,&nbsp;<span class="arg">opt_obj</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span></div>
      </div>


     <div class="entryOverview">
       Builds a new iterator that iterates over the original, but skips elements as
long as a supplied function returns true.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">iterable</span>
        : <div class="fullType">(<span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span><span>&nbsp;|&nbsp;</span><span class="type">{__iterator__: ?}</span><span>&nbsp;|&nbsp;</span><span class="type">{length: number}</span>)</div>
        <div class="entryOverview">The iterator object.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">f</span>
        : <div class="fullType"><span class="type">function (this:T, ?, undefined, ?): boolean</span></div>
        <div class="entryOverview">The function to call for every value. This function takes 3 arguments (the value, undefined, and the iterator) and should return a boolean.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_obj</span>
        : <div class="fullType">(<span class="type">T</span><span>&nbsp;|&nbsp;</span><span class="type">undefined</span>)</div>
        <div class="entryOverview">The object to be used as the value of &amp;#39;this&amp;#39; within <code>f</code>.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span></div>&nbsp;
            A new iterator that drops elements from the original iterator as long as <code>f</code> is true.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_iter_iter.js.source.html#line439">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.iter.equals"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.iter.</span><span class="entryName">equals<span class="args">(<span class="arg">iterable1</span>,&nbsp;<span class="arg">iterable2</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span></div>
      </div>


     <div class="entryOverview">
       Iterates over 2 iterators and returns true if they contain the same sequence
of elements and have the same length.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">iterable1</span>
        : <div class="fullType">(<span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span><span>&nbsp;|&nbsp;</span><span class="type">{__iterator__: ?}</span><span>&nbsp;|&nbsp;</span><span class="type">{length: number}</span>)</div>
        <div class="entryOverview">The first iterable object.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">iterable2</span>
        : <div class="fullType">(<span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span><span>&nbsp;|&nbsp;</span><span class="type">{__iterator__: ?}</span><span>&nbsp;|&nbsp;</span><span class="type">{length: number}</span>)</div>
        <div class="entryOverview">The second iterable object.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span></div>&nbsp;
            true if the iterators contain the same sequence of elements and have the same length.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_iter_iter.js.source.html#line520">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.iter.every"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.iter.</span><span class="entryName">every<span class="args">(<span class="arg">iterable</span>,&nbsp;<span class="arg">f</span>,&nbsp;<span class="arg">opt_obj</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span></div>
      </div>


     <div class="entryOverview">
       Goes through the values in the iterator. Calls f for each these and if any of
them returns false this returns false (without checking the rest). If all
return true this will return true.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">iterable</span>
        : <div class="fullType">(<span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span><span>&nbsp;|&nbsp;</span><span class="type">{__iterator__: ?}</span><span>&nbsp;|&nbsp;</span><span class="type">{length: number}</span>)</div>
        <div class="entryOverview">The iterator object.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">f</span>
        : <div class="fullType"><span class="type">function (this:T, ?, undefined, ?): boolean</span></div>
        <div class="entryOverview">The function to call for every value. This function takes 3 arguments (the value, undefined, and the iterator) and should return a boolean.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_obj</span>
        : <div class="fullType">(<span class="type">T</span><span>&nbsp;|&nbsp;</span><span class="type">undefined</span>)</div>
        <div class="entryOverview">The object to be used as the value of &amp;#39;this&amp;#39; within <code>f</code>.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span></div>&nbsp;
            true if every value passes the test.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_iter_iter.js.source.html#line367">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.iter.filter"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.iter.</span><span class="entryName">filter<span class="args">(<span class="arg">iterable</span>,&nbsp;<span class="arg">f</span>,&nbsp;<span class="arg">opt_obj</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span></div>
      </div>


     <div class="entryOverview">
       Calls a function for every element in the iterator, and if the function
returns true adds the element to a new iterator.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">iterable</span>
        : <div class="fullType">(<span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span><span>&nbsp;|&nbsp;</span><span class="type">{__iterator__: ?}</span><span>&nbsp;|&nbsp;</span><span class="type">{length: number}</span>)</div>
        <div class="entryOverview">The iterator to iterate over.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">f</span>
        : <div class="fullType"><span class="type">function (this:T, ?, undefined, ?): boolean</span></div>
        <div class="entryOverview">The function to call for every element. This function takes 3 arguments (the element, undefined, and the iterator) and should return a boolean.  If the return value is true the element will be included  in the returned iteror.  If it is false the element is not included.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_obj</span>
        : <div class="fullType">(<span class="type">T</span><span>&nbsp;|&nbsp;</span><span class="type">undefined</span>)</div>
        <div class="entryOverview">The object to be used as the value of &amp;#39;this&amp;#39; within <code>f</code>.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span></div>&nbsp;
            A new iterator in which only elements that passed the test are present.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_iter_iter.js.source.html#line197">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.iter.forEach"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.iter.</span><span class="entryName">forEach<span class="args">(<span class="arg">iterable</span>,&nbsp;<span class="arg">f</span>,&nbsp;<span class="arg">opt_obj</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Calls a function for each element in the iterator with the element of the
iterator passed as argument.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">iterable</span>
        : <div class="fullType">(<span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span><span>&nbsp;|&nbsp;</span><span class="type">{__iterator__: ?}</span><span>&nbsp;|&nbsp;</span><span class="type">{length: number}</span>)</div>
        <div class="entryOverview">The iterator to iterate over.  If the iterable is an object <code>toIterator</code> will be called on it.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">f</span>
        : <div class="fullType"><span>?</span><span class="type">function (this:T, ?, ?, ?): </span></div>
        <div class="entryOverview">The function to call for every element.  This function takes 3 arguments (the element, undefined, and the iterator) and the return value is irrelevant.  The reason for passing undefined as the second argument is so that the same function can be used in goog.array#forEach as well as others.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_obj</span>
        : <div class="fullType">(<span class="type">T</span><span>&nbsp;|&nbsp;</span><span class="type">undefined</span>)</div>
        <div class="entryOverview">The object to be used as the value of &amp;#39;this&amp;#39; within <code>f</code>.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_iter_iter.js.source.html#line151">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.iter.join"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.iter.</span><span class="entryName">join<span class="args">(<span class="arg">iterable</span>,&nbsp;<span class="arg">deliminator</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
      </div>


     <div class="entryOverview">
       Joins the values in a iterator with a delimiter.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">iterable</span>
        : <div class="fullType">(<span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span><span>&nbsp;|&nbsp;</span><span class="type">{__iterator__: ?}</span><span>&nbsp;|&nbsp;</span><span class="type">{length: number}</span>)</div>
        <div class="entryOverview">The iterator to get the values from.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">deliminator</span>
        : <div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
        <div class="entryOverview">The text to put between the values.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>&nbsp;
            The joined value string.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_iter_iter.js.source.html#line261">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.iter.map"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.iter.</span><span class="entryName">map<span class="args">(<span class="arg">iterable</span>,&nbsp;<span class="arg">f</span>,&nbsp;<span class="arg">opt_obj</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span></div>
      </div>


     <div class="entryOverview">
       For every element in the iterator call a function and return a new iterator
with that value.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">iterable</span>
        : <div class="fullType">(<span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span><span>&nbsp;|&nbsp;</span><span class="type">{__iterator__: ?}</span><span>&nbsp;|&nbsp;</span><span class="type">{length: number}</span>)</div>
        <div class="entryOverview">The iterator to iterate over.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">f</span>
        : <div class="fullType"><span>?</span><span class="type">function (this:T, ?, undefined, ?): </span></div>
        <div class="entryOverview">The function to call for every element.  This function takes 3 arguments (the element, undefined, and the iterator) and should return a new value.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_obj</span>
        : <div class="fullType">(<span class="type">T</span><span>&nbsp;|&nbsp;</span><span class="type">undefined</span>)</div>
        <div class="entryOverview">The object to be used as the value of &amp;#39;this&amp;#39; within <code>f</code>.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span></div>&nbsp;
            A new iterator that returns the results of applying the function to each element in the original iterator.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_iter_iter.js.source.html#line281">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.iter.nextOrValue"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.iter.</span><span class="entryName">nextOrValue<span class="args">(<span class="arg">iterable</span>,&nbsp;<span class="arg">defaultValue</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type">*</span></div>
      </div>


     <div class="entryOverview">
       Advances the iterator to the next position, returning the given default value
instead of throwing an exception if the iterator has no more entries.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">iterable</span>
        : <div class="fullType">(<span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span><span>&nbsp;|&nbsp;</span><span class="type">{__iterator__: ?}</span><span>&nbsp;|&nbsp;</span><span class="type">{length: number}</span>)</div>
        <div class="entryOverview">The iterable object.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">defaultValue</span>
        : <div class="fullType"><span class="type">*</span></div>
        <div class="entryOverview">The value to return if the iterator is empty.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type">*</span></div>&nbsp;
            The next item in the iteration, or defaultValue if the iterator was empty.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_iter_iter.js.source.html#line573">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.iter.product"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.iter.</span><span class="entryName">product<span class="args">(<span class="arg">var_args</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span></div>
      </div>


     <div class="entryOverview">
       Cartesian product of zero or more sets.  Gives an iterator that gives every
combination of one element chosen from each set.  For example,
([1, 2], [3, 4]) gives ([1, 3], [1, 4], [2, 3], [2, 4]).
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">var_args</span>
        : <div class="fullType">(<span class="type">undefined</span><span>&nbsp;|&nbsp;</span><span class="type">{length: number}</span>)</div>
        <div class="entryOverview">Zero or more sets, as arrays.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span></div>&nbsp;
            An iterator that gives each n-tuple (as an array).
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_iter_iter.js.source.html#line594">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.iter.range"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.iter.</span><span class="entryName">range<span class="args">(<span class="arg">startOrStop</span>,&nbsp;<span class="arg">opt_stop</span>,&nbsp;<span class="arg">opt_step</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span></div>
      </div>


     <div class="entryOverview">
       Creates a new iterator that returns the values in a range.  This function
can take 1, 2 or 3 arguments:
<pre class="lang-js prettyprint">
range(5) same as range(0, 5, 1)
range(2, 5) same as range(2, 5, 1)
</pre>
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">startOrStop</span>
        : <div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span></div>
        <div class="entryOverview">The stop value if only one argument is provided. The start value if 2 or more arguments are provided.  If only one argument is used the start value is 0.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_stop</span>
        : <div class="fullType">(<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span><span>&nbsp;|&nbsp;</span><span class="type">undefined</span>)</div>
        <div class="entryOverview">The stop value.  If left out then the first argument is used as the stop value.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_step</span>
        : <div class="fullType">(<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span><span>&nbsp;|&nbsp;</span><span class="type">undefined</span>)</div>
        <div class="entryOverview">The number to increment with between each call to next.  This can be negative.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span></div>&nbsp;
            A new iterator that returns the values in the range.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_iter_iter.js.source.html#line230">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.iter.reduce"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.iter.</span><span class="entryName">reduce<span class="args">(<span class="arg">iterable</span>,&nbsp;<span class="arg">f</span>,&nbsp;<span class="arg">val</span>,&nbsp;<span class="arg">opt_obj</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type">V</span></div>
      </div>


     <div class="entryOverview">
       Passes every element of an iterator into a function and accumulates the
result.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">iterable</span>
        : <div class="fullType">(<span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span><span>&nbsp;|&nbsp;</span><span class="type">{__iterator__: ?}</span><span>&nbsp;|&nbsp;</span><span class="type">{length: number}</span>)</div>
        <div class="entryOverview">The iterator to iterate over.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">f</span>
        : <div class="fullType"><span class="type">function (this:T, V, ?): V</span></div>
        <div class="entryOverview">The function to call for every element. This function takes 2 arguments (the function's previous result or the initial value, and the value of the current element). function(previousValue, currentElement) : newValue.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">val</span>
        : <div class="fullType"><span class="type">V</span></div>
        <div class="entryOverview">The initial value to pass into the function on the first call.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_obj</span>
        : <div class="fullType">(<span class="type">T</span><span>&nbsp;|&nbsp;</span><span class="type">undefined</span>)</div>
        <div class="entryOverview">The object to be used as the value of 'this' within f.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type">V</span></div>&nbsp;
            Result of evaluating f repeatedly across the values of the iterator.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_iter_iter.js.source.html#line310">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.iter.some"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.iter.</span><span class="entryName">some<span class="args">(<span class="arg">iterable</span>,&nbsp;<span class="arg">f</span>,&nbsp;<span class="arg">opt_obj</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span></div>
      </div>


     <div class="entryOverview">
       Goes through the values in the iterator. Calls f for each these and if any of
them returns true, this returns true (without checking the rest). If all
return false this will return false.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">iterable</span>
        : <div class="fullType">(<span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span><span>&nbsp;|&nbsp;</span><span class="type">{__iterator__: ?}</span><span>&nbsp;|&nbsp;</span><span class="type">{length: number}</span>)</div>
        <div class="entryOverview">The iterator object.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">f</span>
        : <div class="fullType"><span class="type">function (this:T, ?, undefined, ?): boolean</span></div>
        <div class="entryOverview">The function to call for every value. This function takes 3 arguments (the value, undefined, and the iterator) and should return a boolean.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_obj</span>
        : <div class="fullType">(<span class="type">T</span><span>&nbsp;|&nbsp;</span><span class="type">undefined</span>)</div>
        <div class="entryOverview">The object to be used as the value of &amp;#39;this&amp;#39; within <code>f</code>.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span></div>&nbsp;
            true if any value passes the test.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_iter_iter.js.source.html#line334">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.iter.takeWhile"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.iter.</span><span class="entryName">takeWhile<span class="args">(<span class="arg">iterable</span>,&nbsp;<span class="arg">f</span>,&nbsp;<span class="arg">opt_obj</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span></div>
      </div>


     <div class="entryOverview">
       Builds a new iterator that iterates over the original, but only as long as a
supplied function returns true.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">iterable</span>
        : <div class="fullType">(<span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span><span>&nbsp;|&nbsp;</span><span class="type">{__iterator__: ?}</span><span>&nbsp;|&nbsp;</span><span class="type">{length: number}</span>)</div>
        <div class="entryOverview">The iterator object.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">f</span>
        : <div class="fullType"><span class="type">function (this:T, ?, undefined, ?): boolean</span></div>
        <div class="entryOverview">The function to call for every value. This function takes 3 arguments (the value, undefined, and the iterator) and should return a boolean.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_obj</span>
        : <div class="fullType">(<span class="type">T</span><span>&nbsp;|&nbsp;</span><span class="type">undefined</span>)</div>
        <div class="entryOverview">This is used as the 'this' object in f when called.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span></div>&nbsp;
            A new iterator that keeps elements in the original iterator as long as the function is true.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_iter_iter.js.source.html#line471">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.iter.toArray"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.iter.</span><span class="entryName">toArray<span class="args">(<span class="arg">iterable</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span></div>
      </div>


     <div class="entryOverview">
       Converts the iterator to an array
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">iterable</span>
        : <div class="fullType">(<span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span><span>&nbsp;|&nbsp;</span><span class="type">{__iterator__: ?}</span><span>&nbsp;|&nbsp;</span><span class="type">{length: number}</span>)</div>
        <div class="entryOverview">The iterator to convert to an array.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span></div>&nbsp;
            An array of the elements the iterator iterates over.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_iter_iter.js.source.html#line498">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.iter.toIterator"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.iter.</span><span class="entryName">toIterator<span class="args">(<span class="arg">iterable</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span></div>
      </div>


     <div class="entryOverview">
       Returns an iterator that knows how to iterate over the values in the object.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">iterable</span>
        : <div class="fullType">(<span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span><span>&nbsp;|&nbsp;</span><span class="type">{__iterator__: ?}</span><span>&nbsp;|&nbsp;</span><span class="type">{length: number}</span>)</div>
        <div class="entryOverview">If the object is an iterator it will be returned as is.  If the object has a <code>__iterator__</code> method that will be called to get the value iterator.  If the object is an array-like object we create an iterator for that.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="class_goog_iter_Iterator.html">goog.iter.Iterator</a></span></div>&nbsp;
            An iterator that knows how to iterate over the values in <code>iterable</code>.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_iter_iter.js.source.html#line102">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>



  <h2>Global Properties</h2>





<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>





  <a name="goog.iter.StopIteration"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.iter.</span><span class="entryName">StopIteration</span>
        : <div class="fullType">(<span class="type">Error</span><span>&nbsp;|&nbsp;</span><span class="type">null</span>)</div>
     </div>


     <div class="entryOverview">
       Singleton Error object that is used to terminate iterations.
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_iter_iter.js.source.html#line45">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>



      <!-- Column 1 end -->
    </div>

        <div class="col2">
          <!-- Column 2 start -->
          <div class="col2-c">
            <h2 id="ref-head">Directory iter</h2>
            <div id="localView"></div>
          </div>

          <div class="col2-c">
            <h2 id="ref-head">File Reference</h2>
            <div id="sideFileIndex" rootPath="" current="iter/iter.js"></div>
          </div>
          <!-- Column 2 end -->
        </div>
</div>
</div>

</body>
</html>
